home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / 3DTOSHI2.ZIP / mpgui / source / guiframe.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-17  |  7.3 KB  |  257 lines

  1.  
  2. // guiframe.cpp
  3. //
  4. // Copyright (c) 1995 by Toshiaki Tsuji, all rights reserved.
  5.  
  6. #include "stdgfx.h"
  7. #include "guiframe.h"
  8.  
  9. APIRESULT APIPROC GUIFrameProc ( HWINDOW hWindow, MESSAGE iMessage,
  10.                                  PARAM1 Param1, PARAM2 Param2 );
  11.  
  12. #if defined (__FORUNIX__)
  13.   #if defined (__FORMOTIF__)
  14.     VOID GUIFrameXWinProc ( Widget W, XtPointer ClientData, 
  15.                           XEvent *EventPtr ); 
  16.   #endif
  17. #endif
  18.  
  19. //****************************************************
  20. //
  21. // GUI Window Class
  22. //
  23. //****************************************************
  24.  
  25. GUIFRAME *NewFrame=NULL;
  26.  
  27. GUIFRAME::GUIFRAME () : GUIWINDOW ()
  28.   {
  29.     strcpy ( ClassName, "GUIFRAMEWINDOW" );
  30.   } // End of Constructor for GUIFRAME
  31.  
  32. GUIFRAME::~GUIFRAME ()
  33.   {
  34.   } // End of Destructor for GUIFRAME
  35.  
  36. VOID GUIFRAME::RegisterWindow ()
  37.   {
  38.     #if defined (__FORWINDOWS__)
  39.       WNDCLASS WndClass;
  40.       WndClass.cbClsExtra = 0;
  41.       WndClass.cbWndExtra = 0;
  42.       #if defined (__FORWIN386__)
  43.         WndClass.hbrBackground = GetStockObject ( (short)WinBG );
  44.       #else
  45.         WndClass.hbrBackground = GetStockObject ( WinBG );
  46.       #endif
  47.       WndClass.hCursor = LoadCursor ( NULL, IDC_ARROW );
  48.       WndClass.hInstance = (HINSTANCE)hInstance;
  49.       WndClass.hIcon = LoadIcon ( NULL, "END" );
  50.       WndClass.lpfnWndProc = (WNDPROC)GUIFrameProc;
  51.       WndClass.lpszClassName = ClassName;
  52.       WndClass.lpszMenuName = NULL;
  53.       WndClass.style = (UINT)ClassStyle;
  54.  
  55.       RegisterClass ( &WndClass );
  56.  
  57.     #elif defined (__FOROS2__)
  58.       WinRegisterClass ( hAB, ClassName, GUIFrameProc, CS_SIZEREDRAW, 0 );
  59.     #endif
  60.   } // End of ResgisterWindow for GUIFRAME
  61.  
  62. BOOLEAN GUIFRAME::Create ( STRING Title, LONG x, LONG y, LONG Wd, LONG Ht,
  63.                            GUIWINDOW *Parent )
  64.   {
  65.     PreRegister (); 
  66.     RegisterWindow ();
  67.     NewFrame = this;
  68.  
  69.     ParentWindow = Parent;
  70.     HWINDOW hParent;
  71.     HWINDOW hNew;
  72.  
  73.     #if defined (__FORWINDOWS__)
  74.  
  75.       if (Parent==NULL)
  76.         hParent = HDESKTOP;
  77.       else
  78.         hParent = Parent->GetClient ();
  79.  
  80.       #if defined (__FORWIN386__)
  81.         if (WinExStyle==0)
  82.           hWindow = CreateWindow ( ClassName, Title, WinStyle, (short)x, (short)y, (short)Wd,
  83.                                    (short)Ht, hParent, NULL,
  84.                                    (HINSTANCE)hInstance, NULL );
  85.         else
  86.           hWindow = CreateWindowEx ( WinExStyle, ClassName, Title, WinStyle, (short)x, (short)y,
  87.                                      (short)Wd, (short)Ht,
  88.                                      hParent, NULL, hInstance, NULL );
  89.       #else                               
  90.         if (WinExStyle==0)
  91.           hWindow = CreateWindow ( ClassName, Title, WinStyle, x, y, Wd, Ht, hParent, NULL,
  92.                                    hInstance, NULL );
  93.         else
  94.           hWindow = CreateWindowEx ( WinExStyle, ClassName, Title, WinStyle, x, y, Wd, Ht,
  95.                                      hParent, NULL, hInstance, NULL );
  96.       #endif
  97.       
  98.       CreateClientWindow ();
  99.       hNew = hWindow;
  100.  
  101.     #elif defined (__FOROS2__)  
  102.       if (Parent==NULL)
  103.         hParent = HDESKTOP;
  104.       else
  105.         hParent = Parent->GetClient ();
  106.         
  107. /*      ULONG CreateFlag = WinExStyle;
  108.       hWindow = WinCreateStdWindow ( hParent, WinStyle, &CreateFlag, ClassName,
  109.                                      Title, 0, 0, 0, &hClient );*/
  110.       ULONG CreateFlag = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
  111.                               FCF_MINMAX | FCF_TASKLIST | FCF_SHELLPOSITION;
  112.       hWindow = WinCreateStdWindow ( hParent, WS_VISIBLE, &CreateFlag, ClassName,
  113.                                      Title, 0, 0, 0, &hClient );
  114.   
  115.       hNew = hClient;
  116.       if (x&y&Wd&Ht)
  117.         {}
  118.  
  119.     #elif defined (__FORDOS__)
  120.       if (Title)
  121.         {}
  122.       if (x&y&Wd&Ht)
  123.         {}
  124.       if (Parent)
  125.         {}
  126.       if (hParent)
  127.         {}
  128.     #elif defined (__FORUNIX__)
  129.       if (Title)
  130.         {}
  131.       if (x&y&Wd&Ht)
  132.         {}
  133.       if (Parent)
  134.         {}
  135.       if (hParent)
  136.         {}
  137.        #if defined (__FORMOTIF__)
  138.           INT NumArgs;
  139.           Arg MainAttrList[4];
  140.           Widget WinWidget;
  141.  
  142.           XtSetArg ( MainAttrList[0], XmNwidth, Wd );
  143.           XtSetArg ( MainAttrList[1], XmNheight, Ht );
  144.           XtSetArg ( MainAttrList[2], XmNx, x );
  145.           XtSetArg ( MainAttrList[3], XmNy, y );
  146.           WinWidget = XtAppInitialize ( &XtApp, Title, 
  147.                                         NULL, 0, &NumArgs, NULL, NULL, 
  148.                                         MainAttrList, 2 ); 
  149.  
  150.           XtAddCallback ( WinWidget, XmNactivateCallback, GUIFrameXWinProc,
  151.                           NULL );
  152.                           
  153.           XtRealizeWidget ( WinWidget );
  154.            
  155.           MainXDisplay = XtDisplay ( WinWidget );
  156.           hWindow = XtWindow ( WinWidget );
  157.           hClient = hWindow;
  158.           hNew = hClient;     
  159.        #endif   
  160.     #endif
  161.     AddWindow ( this, hNew );
  162.     NewFrame = NULL;
  163.     return SUCCESS;
  164.   } // End of Create for GUIFRAME
  165.  
  166. BOOLEAN GUIFRAME::AddChild ( GUIWINDOW *Child, STRING Title, LONG x, LONG y,
  167.                              LONG Wd, LONG Ht )
  168.   {
  169.     Child->Create ( Title, x, y, Wd, Ht, this );
  170.     return SUCCESS;
  171.   } // End of AddChild for GUIFRAME
  172.  
  173. LONG GUIFRAME::OnCreate ()
  174.   {
  175.     return 0;
  176.   } // End of OnCreate for GUIFRAME
  177.  
  178. LONG GUIFRAME::OnClose ()
  179.   {
  180.     return 0;
  181.   } // End of OnClose for GUIFRAME
  182.  
  183. LONG GUIFRAME::OnDestroy ()
  184.   {
  185.     ExitApplication (0);
  186.     return 0;
  187.   } // End of OnDestroy for GUIFRAME
  188.  
  189. //****************************************************
  190. //
  191. // Frame Window Procedure
  192. //
  193. //****************************************************
  194.  
  195. APIRESULT APIPROC GUIFrameProc ( HWINDOW hWindow, MESSAGE iMessage,
  196.                                  PARAM1 Param1, PARAM2 Param2 )
  197.   {
  198.     LONG Result;
  199.     GUIWINDOW *WinPtr;
  200.  
  201.     Result = 0;
  202.     WinPtr = FindWindow ( hWindow );
  203.     if (WinPtr==NULL)
  204.       {
  205.         if (NewFrame!=NULL)
  206.           Result = NewFrame->WndProc ( hWindow, iMessage, Param1, Param2, FALSE );
  207.       } // End if
  208.     else
  209.       {
  210.         Result = WinPtr->WndProc ( hWindow, iMessage, Param1, Param2, FALSE );
  211.       } // End else
  212.  
  213.     if (Result!=0)
  214.       return 0;
  215.  
  216.     #if defined (__FORWINDOWS__)
  217.       return DefWindowProc ( hWindow, iMessage, Param1, Param2 );
  218.  
  219.     #elif defined (__FOROS2__)
  220.       return WinDefWindowProc ( hWindow, iMessage, Param1, Param2 );
  221.  
  222.     #elif defined (__FORDOS__)
  223.       if (hWindow&iMessage&Param1&Param1)
  224.         {}
  225.       return 0;
  226.     #endif
  227.   } // End of GUIFrameProc
  228.  
  229. #if defined (__FORUNIX__)
  230.   #if defined (__FORMOTIF__)
  231. VOID GUIFrameXWinProc ( Widget W, XtPointer ClientData, 
  232.                       XEvent *EventPtr )
  233.   {
  234.     GUIWINDOW *WinPtr;
  235.     HWINDOW hWindow;
  236.     PARAM1 Param1;
  237.     PARAM2 Param2;
  238.     MESSAGE iMessage;
  239.  
  240.     hWindow = XtWindow ( W );
  241.     WinPtr = FindWindow ( hWindow );
  242.     if (WinPtr==NULL)
  243.       {
  244.       } // End if
  245.     else
  246.       {
  247.         Param1 = EventPtr;
  248.         Param2 = ClientData;
  249.         WinPtr->MapXWinEvent ( &iMessage, EventPtr );
  250.         WinPtr->WndProc ( hWindow, iMessage, Param1, 
  251.                           Param2, FALSE );
  252.        } // End else
  253.     ClearRemovedList ();
  254.   } // End of GUIFrameXWinProc  
  255.   #endif
  256. #endif
  257.